#!/usr/bin/env python
# encoding: utf-8
"""
@author: youfeng
@email: youfeng243@163.com
@license: Apache Licence
@file: asyc_test.py
@time: 2017/8/26 09:05
"""
import tornado.ioloop
import tornado.options
import tornado.web
from tornado import gen
from tornado.httpclient import AsyncHTTPClient


@gen.coroutine
def fetch_coroutine(url):
    response = yield AsyncHTTPClient().fetch(url)
    print response
    raise gen.Return(response)


def main():
    for _ in xrange(10):
        print "开始获取url信息 {}".format(_)
        fetch_coroutine("http://bigdata.sz.haizhi.com/")
        # if r == 200:
        #     print r.body


if __name__ == '__main__':
    main()
    tornado.ioloop.IOLoop.current().start()